package ThirtiethDay;

public class MinCostClimbingStairs {
    public int minCostClimbingStairs(int[] cost) {
        int costa = 0, costb = 0;
        for (int i = 2; i <= cost.length; i++) {
            int temp_cost = costb;
            costb = Math.min(costa + cost[i - 2], costb + cost[i - 1]);
            costa = temp_cost;
        }
        return costb;
    }
}
